home *** CD-ROM | disk | FTP | other *** search
- #include "MultiMonitorDoc.h"
-
- #include <PP_DebugMacros.h>
- #include <PP_KeyCodes.h>
-
- #include <LFile.h>
- #include <LPlaceHolder.h>
- #include <LCheckBoxGroupBox.h>
- #include <LPopupButton.h>
- #include <LPrintout.h>
- #include <LString.h>
- #include <LSlider.h>
- #include <LWindow.h>
- #include <PP_Messages.h>
- #include <UMemoryMgr.h>
- #include <UResourceMgr.h>
- #include <UWindows.h>
-
- #include <AERegistry.h>
-
- #include "AppConstants.h"
- #include "MultiMonitorController.h"
-
- const PaneIDT kPaneID_MMEnable = 'MMEn';
- const PaneIDT kPaneID_MMEffects = 'MMEf';
- const PaneIDT kPaneID_MMSettings1 = 'MMS1';
- const PaneIDT kPaneID_MMSettings2 = 'MMS2';
-
- const MessageT msg_MMEnable = 'MMEn';
- const MessageT msg_MMEffects = 'MMEf';
- const MessageT msg_MMSettings1 = 'MMS1';
- const MessageT msg_MMSettings2 = 'MMS2';
-
-
- // ---------------------------------------------------------------------------------
- // • MultiMonitorDoc [public]
- // ---------------------------------------------------------------------------------
- // Constructor
-
- MultiMonitorDoc::MultiMonitorDoc(
- LCommander * inSuper)
- : LSingleDoc(inSuper)
- {
- // Create window for our document.
- mWindow = LWindow::CreateWindow(PPob_TextWindow, this );
- ValidateObject_(mWindow);
-
- LPane * newPane;
-
- newPane = mWindow->FindPaneByID(kPaneID_MMEnable);
- ValidateObject_(newPane);
- static_cast<LCheckBoxGroupBox *>(newPane)->AddListener(this);
-
- newPane = mWindow->FindPaneByID(kPaneID_MMEffects);
- ValidateObject_(newPane);
- static_cast<LPopupButton *>(newPane)->AddListener(this);
-
- newPane = mWindow->FindPaneByID(kPaneID_MMSettings1);
- ValidateObject_(newPane);
- static_cast<LSlider *>(newPane)->AddListener(this);
-
- newPane = mWindow->FindPaneByID(kPaneID_MMSettings2);
- ValidateObject_(newPane);
- static_cast<LSlider *>(newPane)->AddListener(this);
-
- // Make the window visible.
- mWindow->Show();
- }
-
-
- // ---------------------------------------------------------------------------------
- // • ~MultiMonitorDoc [public, virtual]
- // ---------------------------------------------------------------------------------
- // Destructor
-
- MultiMonitorDoc::~MultiMonitorDoc()
- {
- MultiMonitorController & mmController = MultiMonitorController::GetInstance();
-
- // Disable the multi-monitor controller before
- // going away.
- mmController.Disable();
-
- TakeOffDuty();
- }
-
-
- // ---------------------------------------------------------------------------
- // • FindCommandStatus [public, virtual]
- // ---------------------------------------------------------------------------
- // Override provided here for convenience.
-
- void
- MultiMonitorDoc::FindCommandStatus(
- CommandT inCommand,
- Boolean& outEnabled,
- Boolean& outUsesMark,
- UInt16& outMark,
- Str255 outName)
- {
- LSingleDoc::FindCommandStatus(inCommand, outEnabled, outUsesMark, outMark, outName);
- }
-
-
- // ---------------------------------------------------------------------------
- // • ListenToMessage [public, virtual]
- // ---------------------------------------------------------------------------
-
- void
- MultiMonitorDoc::ListenToMessage(
- MessageT inMessage,
- void* ioParam)
- {
- SInt32 controlValue = *reinterpret_cast<SInt32 *>(ioParam);
- MultiMonitorController & mmController = MultiMonitorController::GetInstance();
-
- switch (inMessage)
- {
- case msg_MMEnable:
- if (controlValue == 0)
- mmController.Disable();
- else
- mmController.Enable();
- break;
-
- case msg_MMEffects:
- mmController.SetEffectsType(controlValue - 1);
-
- LSlider * slider1;
- LSlider * slider2;
- slider1 = static_cast<LSlider *>(mWindow->FindPaneByID(kPaneID_MMSettings1));
- slider2 = static_cast<LSlider *>(mWindow->FindPaneByID(kPaneID_MMSettings2));
-
- if (slider1 != NULL)
- slider1->SetValue(0);
- if (slider2 != NULL)
- slider2->SetValue(0);
- break;
-
- case msg_MMSettings1:
- case msg_MMSettings2:
- mmController.SetEffectsValue(inMessage - msg_MMSettings1, (double)controlValue / 100.0);
- break;
- }
- }
-
-
- // ---------------------------------------------------------------------------
- // • ProcessKeyPress
- // ---------------------------------------------------------------------------
-
- Boolean
- MultiMonitorDoc::HandleKeyPress(
- const EventRecord& inKeyEvent)
- {
- Boolean handled = false;
- MultiMonitorController & mmController = MultiMonitorController::GetInstance();
- LSlider * slider1;
- LSlider * slider2;
-
- slider1 = static_cast<LSlider *>(mWindow->FindPaneByID(kPaneID_MMSettings1));
- slider2 = static_cast<LSlider *>(mWindow->FindPaneByID(kPaneID_MMSettings2));
-
- if (slider1 != NULL && slider2 != NULL)
- {
- // Allow user to control sliders through command-arrows
- if (inKeyEvent.modifiers & cmdKey)
- {
- switch (inKeyEvent.message & charCodeMask)
- {
- case char_LeftArrow:
- slider1->SetValue(slider1->GetValue() - 1);
- handled = true;
- break;
-
- case char_RightArrow:
- slider1->SetValue(slider1->GetValue() + 1);
- handled = true;
- break;
-
- case char_DownArrow:
- slider2->SetValue(slider2->GetValue() + 1);
- handled = true;
- break;
-
- case char_UpArrow:
- slider2->SetValue(slider2->GetValue() - 1);
- handled = true;
- break;
- }
- }
- }
-
- return handled;
- }
-
-
- // ---------------------------------------------------------------------------
- // • ObeyCommand [public, virtual]
- // ---------------------------------------------------------------------------
- // Override provided here for convenience.
-
- Boolean
- MultiMonitorDoc::ObeyCommand(
- CommandT inCommand,
- void* ioParam)
- {
- Boolean cmdHandled = LSingleDoc::ObeyCommand(inCommand, ioParam);
-
- return cmdHandled;
- }
-
-
-